package com.kurumi.util;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

import javax.imageio.ImageIO;

public class FileExistUtil {

	public static void main1(String[] args) {
		try {
			File f = new File("D://test.jpg");
			FileInputStream fi = new FileInputStream(f);
			try {
				BufferedImage sourceImg = ImageIO.read(fi);// 判断图片是否损坏
				int picWidth = sourceImg.getWidth(); // 确保图片是正确的（正确的图片可以取得宽度）
				System.out.println(picWidth);
			} catch (Exception e) {
				// TODO: handle exception
				fi.close();// 关闭IO流才能操作图片

				return;
			} finally {
				fi.close();// 最后一定要关闭IO流
			}
		} catch (Exception e) {
			// TODO: handle exception
			System.out.println(e.toString());
			return;
		}
	}
}
